using System;
using Tool;
using UnityEngine;

namespace Entity.Player
{
    public class PlayerViewController : ActorViewController
    {
        [HideInInspector] public CharacterController moveController; //运动物理系统
        private Player _player => (Player)Actor;
        
        public override void Init()
        {
            base.Init();
            moveController = GetComponent<CharacterController>();
            Player player = new();
            player.Init(ArchiveManager.Instance.EntityData, this);
            Actor = player;
        }

        public void OnGameOver()
        {
            Actor.EntityData.position = transform.localPosition;
            Actor.EntityData.rotation = transform.localRotation.eulerAngles;
            ArchiveManager.Instance.SaveEntityData(0);
            ArchiveManager.Instance.SavePlayerData(0);
        }
    }
}